﻿----------------------------------------------------------------------------------------------------
--
--  © 2012 Stanislav S. Yarmonov.
--
--  TODO:LICENSE
--     
----------------------------------------------------------------------------------------------------
CREATE TABLE [_DB].[Log] (
	-- Log record identifier.
	[ID] [timestamp] NOT NULL,

	-- Date and time, when log record was created.
	[Created] [datetime] NOT NULL,

	-- Log type.
	[Type] [int] NULL,

	-- Log message.
	[Message] [nvarchar](255) NOT NULL,

	-- Log details.
	[Details] [xml] NULL
)
GO

-- Primary key -------------------------------------------------------------------------------------
ALTER TABLE
	[_DB].[Log]
ADD CONSTRAINT
	[PK_DB_Log]
PRIMARY KEY NONCLUSTERED (
	[ID] ASC
)
GO

-- Foreign key to error ----------------------------------------------------------------------------
ALTER TABLE
	[_DB].[Log]
ADD CONSTRAINT
	[FK_DB_Log_Type]
FOREIGN KEY (
	[Type]
) REFERENCES [_DB].[LogType] (
	[ID]
)
GO
